Conversation
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
| finally: | ||
| self._finish_span(span, error) | ||
|
|
||
| async def intercept_client_stream( |
There was a problem hiding this comment.
I only added unit tests for unary for now since I'll probably avoid the stream-type specific interceptors after #149
There was a problem hiding this comment.
A lot :) Rewrote to metadata interceptor so the logic is constant across stream types now
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
Are we able to keep the upstreamed PyPI version completely separated? I think as long as we can do that, it's probably ok to keep in this repo — I think we avoided it with Go because it's annoying to do multi-module versioning in a single repo, and probably borrowed that approach for the -es repos (like @connectrpc/validate). If we can do e.g. tag |
Yeah that should be quite possible - I don't think there's really any special tooling involved, To clarify the other repos
|
stefanvanburen
left a comment
There was a problem hiding this comment.
I think I'm good with the approach on developing this in-repo, rather than splitting it out elsewhere, so forgive me if some of my comments are off-base; I think we can land this probably as-is and continue to iterate on it until it's ready to release.
I'm mostly coming to this from the context of otelconnect-go, which I already only have a passing familiarity with 😅. It might be nice to further spell out how close we're trying to be to that library, where we're making different decisions, etc.
again, happy to land as-is, just trying to pick your brain so I can wrap my head around this a little better.
| RES = TypeVar("RES") | ||
|
|
||
| # Workaround bad typing | ||
| _DEFAULT_TEXTMAP_SETTER = cast("Setter[MutableMapping[str, str]]", default_setter) |
There was a problem hiding this comment.
any upstream issue we ought to follow for this? (I'm not super familiar with the python otel repos.)
There was a problem hiding this comment.
Opening up otel-python repos in an IDE, it's all red ;) I think chasing down typing issues there will be a rabbit hole
| # Vendored in OpenTelemetry semantic conventions for connect-python to avoid | ||
| # unstable imports. We don't copy docstrings since for us they are implementation | ||
| # details and should be obvious enough. |
There was a problem hiding this comment.
Does otel ever stabilize this stuff (/ have a plan to stabilize this stuff)? Just wondering if we need to leave this interceptor at 0.x until it is (or else consider always populating old values?)
There was a problem hiding this comment.
After many many years yeah :) HTTP and DB are finally stable, RPC is at RC. So I think it's safe to use even in a 1.x if we beat them to it
We're definitely not going to use the old attributes for this new library to keep ourselves sane
There was a problem hiding this comment.
BTW in terms of import, I wish python had two artifacts, one with stable and one with incubating, but they only have one with _ imports for incubating, and a ton of cruft from before they had the _ concept. I don't expect their current artifact to ever be 1.x.
I filed open-telemetry/opentelemetry-python#4952 to see if this may change
connectrpc-otel/pyproject.toml
Outdated
| @@ -0,0 +1,61 @@ | |||
| [project] | |||
| name = "connectrpc-otel" | |||
| version = "0.8.1" | |||
There was a problem hiding this comment.
should we land this as 0.1.0?
connectrpc-otel/pyproject.toml
Outdated
| [project] | ||
| name = "connectrpc-otel" | ||
| version = "0.8.1" | ||
| description = "OpenTelemetry middleware for connectrpc" |
There was a problem hiding this comment.
s/middleware/interceptor?
There was a problem hiding this comment.
Went with instrumentation which is the standard term for this in OTel
| finally: | ||
| self._finish_span(span, error) | ||
|
|
||
| async def intercept_client_stream( |
|
|
||
|
|
||
| class RpcSystemNameValues(Enum): | ||
| CONNECTRPC = "connectrpc" |
There was a problem hiding this comment.
since we support gRPC, would we plan on eventually supporting gRPC via this interceptor? or do that elsewhere?
There was a problem hiding this comment.
Yup will add it to this interceptor later
| self, | ||
| *, | ||
| propagator: TextMapPropagator | None = None, | ||
| tracer_provider: TracerProvider | None = None, |
There was a problem hiding this comment.
would we also support stuff like a MeterProvider and the various knobs from otelconnect-go? (there's a lot of Options and I'm honestly not clear which ones are something we'd intend to support here, versus may be vestigial.)
There was a problem hiding this comment.
Yup, will add it with metrics later. Will also consider the options later - some like trust remote, attribute filters, are less common in Python than Go in my experience.
| if ra := environ.get("REMOTE_ADDR"): | ||
| port = environ.get("REMOTE_PORT", "0") |
There was a problem hiding this comment.
this is WSGI stuff, right?
There was a problem hiding this comment.
Actually it's CGI - WSGI was an extension to CGI, so WSGI servers also commonly populate this (except pyvoy since I didn't notice this until writing this PR, will fix it ;) ). Unfortunately WSGI itself doesn't define this at all.
If a server doesn't populate, we don't get it but that's the best we can do - client IP is pretty important in traces to identify bad actors so it's worth the best effort
…nto connectrpc-otel
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
Initial implement with basic tracing / propagation. Follow-ups will add opt-in metadata attributes and metrics.
Some questions
Happy with any direction for these.
https://opentelemetry.io/docs/specs/semconv/rpc/connect-rpc/